package com.chf.job.service.impl;

import com.chf.job.dao.OpenServiceMapper;
import com.chf.job.pojo.OpenService;
import com.chf.job.service.IOpenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OpenServiceImpl implements IOpenService {
    @Autowired
    private OpenServiceMapper openServiceMapper;

    /**
     * 查询是否有开通服务历史记录
     */
    @Override
    public OpenService getByRegisterEmail(String email) {
        return openServiceMapper.getByRegisterEmail(email);
    }

    /**
     * 添加服务
     * @param openService
     * @return
     */
    @Override
    public int addService(OpenService openService) {
        OpenService open = new OpenService();
        open.setVerifyEmail(openService.getVerifyEmail());
        open.setReceiveEmail(openService.getReceiveEmail());
        return openServiceMapper.insertSelective(open);
    }

    /**
     * 更新开通服务
     * @param openService
     * @param email
     * @return
     */
    @Override
    public int updateService(OpenService openService, String email) {

        return openServiceMapper.updateByVerifyEmail(openService.getCompanyName(), email);
    }

    /**
     * 更新服务状态
     * @param email
     * @return
     */
    @Override
    public int updateServiceStatus(String email) {

        return openServiceMapper.updateServiceStatus(email);
    }
}
